package com.uiandtherest.app

import grails.converters.*;
import grails.converters.deep.*;

class TeamController {
	List teams
	List people
	
    def index = { }
	
	def save = { 
			def team = new Team()
			team.name = params.name
			team.mascot = params.mascot
			team.sport = params.sport
			
			team.save()
	}
    
	def jsonList = {
			def json = Team.list(params) 
			render json as JSON
    		
    }
	
	
	
    def xmlList = {
    		teams = Team.list()
    		
    		render(contentType:"text/xml"){
    			teams{
    				for(i in teams){
    					team{
	    					name(i.name)
	    					mascot(i.mascot)
	    					sport(i.sport)
	    					people{
	    						for (p in i.person){
	    						person{
	    							fname(p.fname)
	    							fname(p.lname)
	    						}
	    						}
	    					}
	    					
    					}
    				}
    			}
    		}
    		
    }
	
	
}
